package com.py.credit.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.py.credit.dao.TemplateDao;
import com.py.credit.entity.Model;
import com.py.credit.service.TemplateService;
import com.py.credit.utils.SQLBuilder;
import com.py.framework.core.common.Page;

@Service
public class TemplateServiceImpl implements TemplateService {

	@Autowired
	private TemplateDao templateDao;

	@Override
	public List<Model> getListForPage(String sortType, Page page) {

		return templateDao.getListForPage(sortType, page);
	}

	@Override
	public List<Map<String, Object>> getByConditionForPage(List<String> columns, String[] additionalColumns,
			String conditionStr, Page page) {
		List<String> conditions = SQLBuilder.createConditionSql(conditionStr);
		List<Map<String, Object>> batchLogs = templateDao.selectByConditionForPage(columns, additionalColumns,
				conditions, page);

		return batchLogs;
	}

	@Override
	public Map<String, Object> selectOne(String id) {
		// TODO Auto-generated method stub
		return templateDao.selectOne(id);
	}

	@Override
	public int insert(String name, String mainType, String url, String cjr) {
		// TODO Auto-generated method stub
		return templateDao.insert(name, mainType, url, cjr);
	}

	@Override
	public int update(String name, String mainType, String url, String id) {
		// TODO Auto-generated method stub
		return templateDao.update(name, mainType, url, id);
	}

	@Override
	public int del(List<String> ids) {
		// TODO Auto-generated method stub
		return templateDao.del(ids);
	}

	@Override
	public int setStatus(String id, String status) {
		// TODO Auto-generated method stub
		if (status.equals("2")) {
			status = "1";
		} else {
			status = "2";
		}
		return templateDao.setStatus(id, status);
	}

	@Override
	public List<Map<String, Object>> listForSelect() {
		// TODO Auto-generated method stub
		return templateDao.listForSelect();
	}

}
